package com.xsky.logic.tabcase;

import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.PropertyUtils;

import com.xsky.operation.vo.TabCase;

import junit.framework.TestCase;

public class CaseLogicTest extends TestCase {

	public void testPropeties() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		TabCase tabcase = new TabCase();
		tabcase.setCaseNo("1");
		tabcase.setOperatorId("123");

		PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(TabCase.class);
		for (PropertyDescriptor pd : pds) {
			System.out.println(pd.getName());

		}

		assertEquals(PropertyUtils.getProperty(tabcase, "caseNo"), "1");
		assertEquals(PropertyUtils.getProperty(tabcase, "operatorId"), "123");

		StringBuilder sb = new StringBuilder();
		sb.append(" 1 = 1 ");
		for (PropertyDescriptor pd : pds) {
			String name = pd.getName();
			Object value = PropertyUtils.getProperty(tabcase, pd.getName());
			if (value != null && !name.equals("class")) {
				sb.append(" and "+name + " = " + value.toString());
			}
		}
		System.out.println(sb.toString());
	}

}
